import C from '@/utils/C';

// 所需的组件
const plugins = [
    
];

/** 异步加载高德地图 */
export function loadAMap(ps){
    if(ps) plugins = ps;

    return new Promise((resolve, reject) => {
        if(window.AMap) resolve();
        window.init = function(){ resolve(); }

        const script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = 'https://webapi.amap.com/maps?v=2.0&key='+C.amapJskey+'&plugin='+plugins.join(',')+'&callback=init';
        script.onerror = reject;
        document.head.appendChild(script);
    });
}